package com.itheima.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.pojo.OrderSetting;
import com.itheima.service.OrderSettingService;
import com.itheima.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Set;

/**
 * 定时清理预约
 */
public class ClearOrderSetting {
    @Reference
    OrderSettingService orderSettingService;
    public void DeleOrderSetting(){
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.format(date);//获取当前系统时间
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);//使用给定的 Date设置此日历的时间。
        //set（）：将给定的的日历字段设置为给定得值  get（）：返回给定的日历字段的值
        calendar.set(Calendar.MONTH,calendar.get(Calendar.MONTH)-1);
        date = calendar.getTime();
        String month = dateFormat.format(date);//当前系统上一个月时间
        orderSettingService.DeleOrderSetting(month);//调用DeleOrderSetting方法清理orderSetting
        System.out.println("清理预约设置历史数据完成");
    }
}
